import cv2 as cv
import numpy as np


def main():

    # 读入图像
    img = cv.imread('123.png')
    cv.imshow('box_in_scene', img)
    # 将图像转为灰度图像
    gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)

    # 创建SIFT类对象
    sift = cv.SIFT_create()
    # 检测SIFT关键点
    kp = sift.detect(gray, None)

    # 绘制关键点
    cv.drawKeypoints(gray, kp, img)
    cv.imshow('sift_keypoints_1', img)
    # 绘制关键点（包括大小和方向）
    # cv.drawKeypoints(gray, kp, img,
    # flags = cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
    # cv.imshow('sift_keypoints_2', img)
    cv.waitKey()
    cv.destroyAllWindows()


if __name__ == '__main__':
    main()